<?php
namespace Admin\Model;
use Think\Model;
class UserModel extends Model {
	public function addUser($data){
		//会员新增
		$user = D('user');
		$data['createunixtime'] = time();
		$data['createtime'] = date("Y-m-d H:i:s", time());
		$userResult = $user->add($data);
		return $userResult;
	}
	
	public function addAllUser($dataList){
		//会员批量新增
		$user = D('user');
		$userResult = $user->addAll($dataList);
		return $userResult;
	}
	
	 /**
     * 会员更新
     */
	public function saveUser($data){
		//会员更新
		$user = D('user');
		$userResult = $user->save($data);
		return $userResult;
	}
		
    /**
     * 获取用户信息
     */
    public function getUserItem($where) {
		$user = D('user');
		$result = $user->where($where)->find();
		return $result;
    }
    public function getUserFile($where){
        $user = D('user');
        $result = $user->field("userid,nickname")->where($where)->find();
        return $result;
    }
	
    /**
     * 获取用户列表
     */
    public function getUserList($where){
    	$user = D('user');
		$result = $user->where($where)->select();
		return $result;
    }
   
    /**
     * 用户开启关闭
     */
    public function isUsed($where,$data){
		$user = D('user');
		$userResult = $user->where($where)->save($data);
		return $userResult;
    	
    }
    
    /**
     * 会员更新
     */
    public function UpUser($where,$data){
        //会员更新
        $user = D('user');
        $userResult = $user->where($where)->save($data);
        return $userResult;
    }
    /**
     * 根据条件获取会员数量
     * @param unknown $where
     * @return unknown
     */
    public function getUserCount($where){
        $user = D('user');
        $count = $user->where($where)->count();
        return $count;
    }
    /**
     * 分页获取用户列表
     * @param   $where
     * @param   $page
     * @return  
     */
    public function getUserBypage($where,$page){
        $user = D('user');
        $userList = $user->where($where)->page($page)->select();
        return $userList;
    }
} 